package com.usefullc.english.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.english.domain.UserSubtitle;
import com.usefullc.english.mapper.UserSubtitleMapper;
import com.usefullc.english.query.UserSubtitleQuery;
import com.usefullc.english.vo.UserSubtitleVo;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.service.AbstractBizService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户字幕服务类
 * @author: 星空
 * @date: 2022-08-11
 */
@Service
public class UserSubtitleService extends AbstractBizService<UserSubtitleMapper, UserSubtitle, UserSubtitleQuery> {


    @Override
    protected QueryWrapper<UserSubtitle> getQueryWrapper(UserSubtitleQuery query) {
        QueryWrapper<UserSubtitle> queryWrapper = super.getQueryWrapper(query);
        return queryWrapper;
    }

    public Pager<UserSubtitleVo> findVoByPage(UserSubtitleQuery query){
        Pager<UserSubtitle> page = this.findByPage(query);
        Pager<UserSubtitleVo> newPage = new Pager<>(page);
        List<UserSubtitle> dataList = page.getDataList();
        List<UserSubtitleVo> newDataList = new ArrayList<>();
        newPage.setDataList(newDataList);
        for (UserSubtitle userSubtitle : dataList) {
            UserSubtitleVo userSubtitleVo = BeanUtils.beanCopy(userSubtitle, UserSubtitleVo.class);
            newDataList.add(userSubtitleVo);
        }
        return newPage;
    }


}
